<?php 
class ErrorController extends QSource_System_Controller_Action
{
	public function init(){
		$this->loadTemplate('default');
    	$request = $this->_request->getParams();
    	$this->view->request = $request;
	}
	public function errorAction()
	{		
		// Ensure the default view suffix is used so we always return good
		// content
	//	$this->_helper->viewRenderer->setViewSuffix('phtml');
		
		// Grab the error object from the request
		$errors = $this->_request->getParam('error_handler');
		switch ($errors->type) {
			case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
			case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
		// 404 error -- controller or action not found
			$this->getResponse()->setHttpResponseCode(404);
			$this->view->message = 'Page not found';
			$this->view->code  = 404;
			if ($errors->type == Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER) {
			$this->view->info = sprintf(
			'Unable to find controller "%s" in module "%s"',
			$errors->request->getControllerName(),
			$errors->request->getModuleName()
			);
			}
			if ($errors->type == Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION) {
				$this->view->info = sprintf(
				'Unable to find action "%s" in controller "%s" in module "%s"',
				$errors->request->getActionName(),
				$errors->request->getControllerName(),
				$errors->request->getModuleName()
				);
			}
			break;
			case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
			default:
			// application error
			$this->getResponse()->setHttpResponseCode(500);
			$this->view->message = 'Application error';
			$this->view->code  = 500;
			$this->view->info  = $errors->exception;
			break;
		}
		//$this->_redirect('/');
	}
}